package com.tanhua.dubbo.api.mongo;

import com.tanhua.domain.mongo.Voice;
import org.apache.dubbo.config.annotation.Service;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

/**
 * 圈子服务实现类
 * 点赞
 * 喜欢
 * 评论
 */
@Service
public class VoiceImpl implements VoiceApi {
    @Autowired
    private MongoTemplate mongoTemplate;


    /**
     * 桃花传音-接收语音 根据语言动态id 查询发布的语言动态信息表
     */
    @Override
    public Voice queryById(ObjectId id) {
        Query query = new Query();

        query.addCriteria(Criteria.where("id").is(id));

        Voice voice = mongoTemplate.findOne(query, Voice.class);

        return voice;


    }
    /**
     * 桃花传音-发布语音 插入信息到语音发表
     */
    @Override
    public void add(Voice voice) {
        mongoTemplate.insert(voice);
    }

}
